//
//  LXAuthorCollectionReusableView.m
//  喜马拉雅改良版框架
//
//  Created by liuxin on 15/12/23.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "LXAuthorCollectionReusableView.h"

@implementation LXAuthorCollectionReusableView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    UIImageView *image = [[UIImageView alloc]init];
    image.image = [UIImage imageNamed:@"findsection_logo@2x.png"];
    [self addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(8);
        make.bottom.mas_equalTo(-8);
        make.width.mas_equalTo(14);
    }];
    
    self.titleLabel = [[UILabel alloc]init];
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(image.mas_right).offset(5);
        make.top.mas_equalTo(5);
        make.bottom.mas_equalTo(-5);
        make.width.mas_equalTo(100);
    }];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    [button setTitle:@"更多>" forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:15];
    [self addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(5);
        make.bottom.mas_equalTo(-5);
        make.width.mas_equalTo(60);
    }];
}
-(void)setTitle:(NSString *)title{
    self.titleLabel.text = title;
    self.titleUpReturn = title;
}
-(void)setName:(NSString *)name{
    self.titleReturn = name;
}
-(void)buttonAction:(UIButton*)btn{
    [self.authorDelegate moreAuthor:self.titleReturn title:self.titleUpReturn];
}
@end
